#ifndef __USART_H
#define __USART_H
#include "includes.h"
#include <stdbool.h>

#define ARRAYNUM(arr_name)     (uint32_t)(sizeof(arr_name) / sizeof(*(arr_name)))

typedef struct
{
    uint8_t Rx_Buf[1024];
    uint8_t Tx_Buf[256];

    volatile bool    Rx_Complete;
    bool    Tx_Complete;

    bool    Tx_Idle;

    uint16_t Frame_Len;
}Com;

typedef enum
{
    RX,
    TX
}COM_DIRECTION_t;


void usart_config(void);
void usart0_tx(uint8_t *buf, uint32_t len);
bool get_usart0_rx_flag(void);
void clear_rx_flag(void);
void clear_usart0_rx_buf(void);
void set_rs485_direction(COM_DIRECTION_t DIRECTION);


extern Com Com0;
#endif
